package org.example.springboot.controller;

import org.example.springboot.model.InBound;
import org.example.springboot.model.OutBound;
import org.example.springboot.service.InBoundService;
import org.example.springboot.service.OutBoundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
public class OutBoundController {

    @Autowired
    private OutBoundService outBoundService;

    @PostMapping("/insertOutBound")
    public String insertOutBound(@RequestBody OutBound outBound){
        return outBoundService.insertOutBound(outBound.getProductName(),outBound.getModelNumber(),outBound.getSupplierName(),outBound.getQuantity(),outBound.getTotalAmount(),outBound.getOutTime(),outBound.getOutOrderId());
    }

    @GetMapping("/getAllOutBound")
    public List<OutBound> getAllOutBound(){
        return outBoundService.getAllOutBound();
    }

    @GetMapping("/findOutBoundByKeyword/{keyword}")
    public List<OutBound> findOutBoundByKeyword(@PathVariable String keyword){
        return outBoundService.findOutBoundByKeyword(keyword);
    }

    @GetMapping("/getOutBoundById/{id}")
    public OutBound getOutBoundById(@PathVariable int id){
        return outBoundService.getOutBoundById(id);
    }

    @DeleteMapping("/deleteOutBoundById/{id}")
    public void deleteOutBoundById(@PathVariable int id){
        outBoundService.deleteOutBoundById(id);
    }
}
